package admin;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;

import shop.*;
import admin.*;

import com.opensymphony.xwork2.ActionSupport;
import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;

import java.util.*;
import java.io.Reader;
import java.io.IOException;

import member.Memberbean;

import org.apache.struts2.interceptor.SessionAware;
import com.opensymphony.xwork2.ActionContext;
import java.util.Map;

public class AdminOrderListAction extends ActionSupport implements SessionAware{

	public static Reader reader;
	public static SqlMapClient sqlMapper;
	Map session;
	
	private int countsum;
	private int ORDER_NUM;
	
	private List<OrderBean> list = new ArrayList<OrderBean>(); 
	private Memberbean member = new Memberbean();
	private OrderBean result = new OrderBean();
	
	public AdminOrderListAction() throws IOException {
		reader = Resources.getResourceAsReader("sqlMapConfig.xml");
		sqlMapper = SqlMapClientBuilder.buildSqlMapClient(reader);
		reader.close();

	}
	
	public String execute() throws Exception {
		
		ActionContext context=ActionContext.getContext();
		Map<String,Object> session = context.getSession();		
		String id=(String)session.get("session_m_id");
		
		if(session.size()>0){
			list = sqlMapper.queryForList("selectAlladmin-g");
			member = (Memberbean) sqlMapper.queryForObject("getMember", id);
			countsum = (int)sqlMapper.queryForObject("countsum");
			result.setORDER_NUM(countsum);
		}
		return SUCCESS;
	}

	public List<OrderBean> getList() {
		return list;
	}
	public void setList(List<OrderBean> list) {
		this.list = list;
	}
	public Map getSession() {
		return session;
	}
	public void setSession(Map session) {
		this.session = session;
	}
	public Memberbean getMember() {
		return member;
	}
	public void setMember(Memberbean member) {
		this.member = member;
	}
	public OrderBean getResult() {
		return result;
	}
	public void setResult(OrderBean result) {
		this.result = result;
	}
	public int getORDER_NUM() {
		return ORDER_NUM;
	}
	public void setORDER_NUM(int ORDER_NUM) {
		this.ORDER_NUM = ORDER_NUM;
	}
}
